package com.fallsvc.re.javase.exception;

public class LogIn {
    private static String userName = "admin";
    private static String password = "123456";

    public static void loginInfo(String u, String p) throws UserNameException, PasswordException {
        if (!userName.equals(u)) {
            throw new UserNameException("用户名错误!");
        }
        if (!password.equals(p)) {
            throw new PasswordException("密码错误!");
        }
        System.out.println("登陆成功");
    }

    public static void main(String[] args) {
        try {
            loginInfo("admin", "123456");
        } catch (UserNameException e) {
            e.printStackTrace();
        } catch (PasswordException e) {
            e.printStackTrace();
        }
    }
}